begin tran

declare @upd_id int 
select @upd_id = convert(int, var_data) 
from igs_parm with(updlock) where var_name = 'gv_upd_id'

update pos_sku set color_id = a.new_color_id
from tmp_color a
where pos_sku.style_no = a.style_no and pos_sku.color_id = a.org_color_id

update ms_style set upd_id = @upd_id 
from tmp_color a
where a.style_no = ms_style.style_no

update pur_sizecolor set color_id = c.new_color_id
from pur_dtl d, pur_sizecolor q, tmp_color c
where d.style_no = c.style_no and d.pur_id = q.pur_id and d.seq_no = q.seq_no and q.color_id = c.org_color_id
rollback tran
